package com.woniuxy.rbac.mapper;

import com.woniuxy.rbac.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 用户Mapper接口
 *
 * @Auther: L
 */
@Mapper
public interface UserMapper {
    /**
     * 增加用户
     *
     * @param user
     */
    @Insert("insert into rbac_user(account,password,status) values(#{account},#{password},#{status})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insert(User user);

    /**
     * 查询所有的用户
     *
     * @return
     */
    @Select("select * from rbac_user")
    List<User> list();

    @Delete("delete from rbac_user where id=#{id}")
    void del(int id);

    /**
     * 根据账号查询用户
     *
     * @param account 账号
     * @return
     */
    @Select("select * from rbac_user where account=#{account}")
    User getByAccount(String account);

}
